﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VentaElectrodomesticos.Negocio;

namespace VentaElectrodomesticos.TableroControl
{
    public partial class FormTableroControl : Form
    {
        private static FormTableroControl instance;
        private TableroDeControlNegocio negocio = new TableroDeControlNegocio();
        private List<string> aMostrar;

        public static FormTableroControl getInstance()
        {
            if (instance == null)
                instance = new FormTableroControl();
            return instance;
        }

        public FormTableroControl()
        {
            InitializeComponent();
        }

        private void FormTableroControl_FormClosing(object sender, FormClosingEventArgs e)
        {
            instance = null;
        }

        private void FormTableroControl_Load(object sender, EventArgs e)
        {
            this.cbSucursales.DataSource = new SucursalNegocio().getAll();
            this.cbSucursales.DisplayMember = "Direccion";
            this.cbSucursales.ValueMember = "Id";
        }

        private void bConsultar_Click(object sender, EventArgs e)
        {
            this.consultar();                
        }

        private void consultar()
        {
            this.aMostrar = this.negocio.getTableroControlData(Convert.ToInt32(this.cbSucursales.SelectedValue), this.numYear.Value);
            this.actualizarCampos(aMostrar);
        }

        private void actualizarCampos(List<string> aMostrar)
        {
            this.tbTotVentas.Text = aMostrar[0];
            this.tbTotFacturacion.Text = aMostrar[1];
            this.tbMayorFactura.Text = aMostrar[2];
            this.tbFormaPago.Text = aMostrar[3] + "-" + aMostrar[4];
            this.tbNombreCliente.Text = aMostrar[5];
            this.tbApellidoCliente.Text = aMostrar[6];
            this.tbDniCliente.Text = aMostrar[7];
            this.tbNombreVendedor.Text = aMostrar[8];
            this.tbApellidoVendedor.Text = aMostrar[9];
            this.tbDniVendedor.Text = aMostrar[10];
            this.tbCodigoProducto.Text = aMostrar[11];
            this.tbNombreProducto.Text = aMostrar[12];
            this.tbCategoriaProducto.Text = aMostrar[13];
            this.tbCodigoFaltante.Text = aMostrar[14];
            this.tbDiasFaltante.Text = aMostrar[15];
        }
    }
}
